/**
 * related to image-browser.ui
 * 
 * @Author : meitehudon
 * @Timestamp : 2016-11-08
 */
var app = sm('do_App');
var page = sm("do_Page");
var nf = sm("do_Notification");
var imHelper = require("helper/im");
var images = JSON.parse(page.getData().imgDatas);
var imgIndex = JSON.parse(page.getData().index);
var browser = ui( 'browser' );
browser.index = imgIndex;
var labelIndex = ui("labelIndex");
var labelTotal = ui("labelTotal");
labelIndex.text = imgIndex+1;
labelTotal.text = images.length;
browser.on('indexChanged', function (index){
	imgIndex = this.index;
	labelIndex.text = this.index+1;
}).bindItems(images);

browser.on( 'touch', function (){
	app.closePage();
});
page.on("back", function() {
    app.closePage();
});

var layoutSave = ui("layoutSave");
layoutSave.on("touch","",300,function(){
	imHelper.downloadImage(images[imgIndex].source);
})
